﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Inaction.Core;
using Inaction.Mapping;
using Inaction.Security;

namespace Inaction.Business.Security.Abstract
{
    [Table("UserInfo"), DisplayName("用户"), Serializable]
    public abstract class UserInfo<T> : Inaction.Business.Entity<T> where T : UserInfo<T>, new()
    {
        #region 属性

        public static readonly Property<Guid?> IdProperty = RegisteProperty<Guid?>(p => p.Id);
        Guid? _id;
        [Column("Id"), DisplayName("用户"), Display(Description = "用户")]
        public Guid? Id
        {
            get { return _id; }
            internal set { SetProperty(IdProperty, ref _id, value); }
        }

        public static readonly Property<String> NameProperty = RegisteProperty<String>(p => p.Name);
        String _name;
        [Column("Name"), DisplayName("名称"), Display(Description = "名称")]
        public String Name
        {
            get { return _name; }
            set { SetProperty(NameProperty, ref _name, value); }
        }

        public static readonly Property<String> NumberProperty = RegisteProperty<String>(p => p.Number);
        String _number;
        [Column("Number"), DisplayName("帐号"), Display(Description = "帐号")]
        public String Number
        {
            get { return _number; }
            set { SetProperty(NumberProperty, ref _number, value); }
        }

        public static readonly Property<Byte[]> PasswordProperty = RegisteProperty<Byte[]>(p => p.Password);
        Byte[] _password;
        [Column("Password"), DisplayName("密码"), Display(Description = "密码")]
        public Byte[] Password
        {
            get { return _password; }
            set { SetProperty(PasswordProperty, ref _password, value); }
        }

        public static readonly Property<UserType?> UserTypeProperty = RegisteProperty<UserType?>(p => p.UserType, Inaction.Security.UserType.User);
        UserType? _userType;
        [Column("UserType"), DisplayName("用户类型"), Display(Description = "用户类型")]
        public UserType? UserType
        {
            get { return _userType; }
            set { SetProperty(UserTypeProperty, ref _userType, value); }
        }

        public static readonly Property<Guid?> DepartmentIdProperty = RegisteProperty<Guid?>(p => p.DepartmentId);
        Guid? _departmentId;
        [Column("DepartmentId"), DisplayName("所属部门"), Display(Description = "所属部门")]
        public Guid? DepartmentId
        {
            get { return _departmentId; }
            set { SetProperty(DepartmentIdProperty, ref _departmentId, value); }
        }

        public static readonly Property<String> EmailProperty = RegisteProperty<String>(p => p.Email);
        String _email;
        [Column("Email"), DisplayName("Email"), Display(Description = "Email")]
        public String Email
        {
            get { return _email; }
            set { SetProperty(EmailProperty, ref _email, value); }
        }

        public static readonly Property<String> TelProperty = RegisteProperty<String>(p => p.Tel);
        String _tel;
        [Column("Tel"), DisplayName("联系电话"), Display(Description = "联系电话")]
        public String Tel
        {
            get { return _tel; }
            set { SetProperty(TelProperty, ref _tel, value); }
        }

        public static readonly Property<String> RemarkProperty = RegisteProperty<String>(p => p.Remark);
        String _remark;
        [Column("Remark"), DisplayName("备注"), Display(Description = "备注")]
        public String Remark
        {
            get { return _remark; }
            set { SetProperty(RemarkProperty, ref _remark, value); }
        }


        public static readonly Property<String> CreaterProperty = RegisteProperty<String>(p => p.Creater);
        String _creater;
        [Column("Creater"), DisplayName("创建人"), Display(Description = "创建人"), Browsable(false)]
        public String Creater
        {
            get { return _creater; }
        }

        public static readonly Property<DateTime?> CreateTimeProperty = RegisteProperty<DateTime?>(p => p.CreateTime);
        DateTime? _createTime;
        [Column("CreateTime"), DisplayName("创建时间"), Display(Description = "创建时间"), Browsable(false)]
        public DateTime? CreateTime
        {
            get { return _createTime; }
        }

        public static readonly Property<String> UpdaterProperty = RegisteProperty<String>(p => p.Updater);
        String _updater;
        [Column("Updater"), DisplayName("修改人"), Display(Description = "修改人"), Browsable(false)]
        public String Updater
        {
            get { return _updater; }
        }

        public static readonly Property<DateTime?> UpdateTimeProperty = RegisteProperty<DateTime?>(p => p.UpdateTime);
        DateTime? _updateTime;
        [Column("UpdateTime"), DisplayName("修改时间"), Display(Description = "修改时间"), Browsable(false)]
        public DateTime? UpdateTime
        {
            get { return _updateTime; }
        }

        public static readonly Property<Boolean?> DeletedProperty = RegisteProperty<Boolean?>(p => p.Deleted);
        Boolean? _deleted;
        [Column("Deleted"), DisplayName("是否删除"), Display(Description = "是否删除"), Browsable(false)]
        public Boolean? Deleted
        {
            get { return _deleted; }
        }

        #endregion
    }
}
